#pragma once
#include <bitset>
#include <memory>
#include <vector>

#include "move_component.h"

class FindPathSystem;
class MapSystem;
class Entity : public std::enable_shared_from_this<Entity> {
 public:
  enum EntityStatus {
    kEntityStatusNone = 0,
    kEntityStatusDataReady,
    kEntityStatusReady,
    kEntityStatusInMap,
    kEntityStatusRemove,
  };

  Entity(MapSystem& map_system, EntityType type);
  ~Entity();

  void Init(const Vector2D& direction, const ZNumber& sacle,
            const ZNumber &collision, const Vector2D& position);

  MapSystem* GetMapSystem() { return &map_system_; }

  void SetEntityId(uint64_t id) { id_ = id; }
  inline uint64_t GetEntityId() const { return id_; }
  EntityType GetEntityType() { return type_;}
  EntityStatus GetStatus() { return status_; }
  void SetStatus(EntityStatus status) { status_ = status; }

  MoveComponent* GetMoveComponent() { return &move_compoent_; }

  inline bool IsInMap() const { return is_in_map_; }
  void SetIsInMap(bool is_in_map);

  inline const ZNumber& GetScale() const { return scale_; }
  const ZNumber& GetCollision() const { return collision_; }
  void SetCollision(const ZNumber& collision);
  Vector2D GetCenterPosition();
  inline const Vector2D& GetPosition() const { return position_; }
  void SetPosition(const Vector2D& position);

  inline const Vector2D& GetDirection() const { return direction_; }
  void SetDirection(const Vector2D& direction);

  void SetSacle(const ZNumber& scale);
  void SetSpeed(int32_t speed);

 private:
  uint64_t id_;
  EntityStatus status_;
  MoveComponent move_compoent_;
  EntityType type_;

  bool is_in_map_;

  Vector2D position_;
  Vector2D direction_;
  ZNumber scale_;
  ZNumber collision_;

  MapSystem& map_system_;

};

using EntityPtr = std::shared_ptr<Entity>;
